<slave>
	<name>{{ salt['pillar.get']('jenkins:node_name', '') }}</name>
	<description></description>
	<remoteFS>/home/jenkins</remoteFS>
	<numExecutors>2</numExecutors>
	<mode>EXCLUSIVE</mode>
	<retentionStrategy class="hudson.slaves.RetentionStrategy\$Always"/>
	<launcher class="hudson.plugins.sshslaves.SSHLauncher" plugin="ssh-slaves@1.11">
		<host>{{ salt['pillar.get']('jenkins:slave_host', '') }}</host>
		<port>22</port>
		{% set jenkins_master = salt['grains.get']('jenkins:master', '') %}
		<credentialsId>{{ salt['pillar.get']('jenkins:credentials:' + jenkins_master,'') }}</credentialsId>
	</launcher>
	<label>{{ salt['pillar.get']('jenkins:node_name', '') }}</label>
	<nodeProperties>
        {% set env_dict = salt['pillar.get']('jenkins:slave_env', {}) %}
        {% if env_dict|length > 0 %}
        <hudson.slaves.EnvironmentVariablesNodeProperty>
          <envVars serialization="custom">
            <unserializable-parents/>
            <tree-map>
              <default>
                <comparator class="hudson.util.CaseInsensitiveComparator"/>
              </default>
              <int>{{ env_dict|length }}</int>
              {% for env, value in env_dict.items() %}
              <string>{{ env }}</string>
              <string>{{ value }}</string>
              {% endfor %}
            </tree-map>
          </envVars>
        </hudson.slaves.EnvironmentVariablesNodeProperty>
        {% endif %}
	</nodeProperties> 
</slave>
 